package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckGroupMapper {
    /**
     * 增加项目组
     * @param checkGroup
     * @return
     */
    @Insert("insert into t_checkgroup(code, name, helpCode, sex, remark, attention) value(#{code},#{name},#{helpCode},#{sex},#{remark},#{attention}) ")
     boolean add(CheckGroup checkGroup) ;
    @Insert("insert into t_checkgroup_checkitem(checkgroup_id, checkitem_id)  value(#{id},#{itemId})")
    boolean CheckGroupInItem(Integer id,Integer itemId);

    /**
     * 查找所有检查组
     * @return
     */
    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

    /**
     * 跟据id查找检查组
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id=#{id}")
    CheckGroup findeById(Integer id);
    /**
     * 根据id删除检查组
     * @param id
     * @return
     */
    @Delete("delete from t_checkgroup where id=#{id}")
    boolean deleteById(Integer id);
    /**
     * 根据套餐id查询关联的检查项id
     * @param setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id =#{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);
    /**
     * 编辑
     * @param checkGroup
     * @return
     */
    boolean edit(CheckGroup checkGroup);
    @Update("update t_checkgroup_checkitem set checkitem_id = #{itemId} where checkgroup_id = #{id}")
    boolean editGroup(Integer itemId,Integer id);
}
